<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>过滤器</title>
    <script src="../vue2.js"></script>
    <script src="../axios.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul, li {
            list-style: none;
        }

        .header {
            width: 100%;
            height: 50px;
            background-color: #fff;
            display: flex;
            position: fixed;
            top: 0;
            box-shadow: 0 1px 5px #d2d2d2;
            z-index: 999;
        }

        .header div {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;

        }

        .header div span {
            cursor: pointer;
            line-height: 45px;
        }

        .header div span.active {
            color: #ff8432;
            border-bottom: 2px solid #ff8432;
        }

        .body {
            padding-left: 15px;
            color: #4d4d4d;
            margin-top: 50px;
        }

        .body li .box-list {
            width: 100%;
            height: 140px;
            padding: 5px 0;
            box-sizing: border-box;
            display: flex;
            align-items: center;
        }

        .body .box-list img {
            width: 70px;
            height: 100px;
            border-radius: 3px;
        }

        .body .box-list .formal {
            flex: 1;
            display: flex;
            justify-content: space-between;
            /*border: 1px solid red;*/
        }

        .body .box-list .info {
            /*width: 200px;*/
            font-size: 15px;
            margin-left: 10px;
            padding: 15px 0;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .body .box-list .info .title {
            font-size: 20px;
            font-weight: 500;
            margin-bottom: 5px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            /* 能够显示的行数，超出部分用...表示*/
            -webkit-box-orient: vertical;
        }

        .body .box-list .info .title {
            -webkit-line-clamp: 1;
        }

        .body .box-list .info .title span {
            font-size: 12px;
            height: 12px;
            color: #fff;
            padding: 0 2px;
            background-color: #d3d3d3;
            border-radius: 3px;
        }

        .body .box-list .info .grade {
            color: #ff8432;
            line-height: 12px;
        }

        .body .box-list .info .text {
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 1; /* 能够显示的行数，超出部分用...表示*/
            -webkit-box-orient: vertical;
        }

        .body .box-list .info .nation-runtime {
            display: flex;
            align-items: center;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 1; /* 能够显示的行数，超出部分用...表示*/
            -webkit-box-orient: vertical;
        }

        .body .box-list .btn {
            max-width: 70px;
            min-width: 65px;
            position: relative;
            /*border: 1px solid red;*/
        }

        .body .box-list button {
            font-size: 12px;
            padding: 3px 12px;
            color: #ff8432;
            background-color: #fff;
            border: 1px solid #ff8432;
            border-radius: 2px;
            outline: none;
            position: absolute;
            top: 50%;
            right: 15px;
            transform: translateY(-50%);
            z-index: 0;
        }

        .body li .part {
            width: 100%;
            height: 1px;
            background-color: #c9c9c9;
        }
    </style>
</head>
<body>
<div id="box">
    <div class="header">
        <div>
            <span :class="switchClass?'':'active'" @click="handleHot">正在热映</span>
        </div>
        <div>
            <span :class="switchClass?'active':''" @click="handleComing">即将上映</span>
        </div>
    </div>

    <div class="body">
        <ul>
            <li v-for="item in datalist" :key="item.filmId">
                <div class="box-list">
                    <img :src="item.img | imgFilter" alt="">
                    <div class="formal">
                        <div class="info">
                            <div class="title">
                                {{ item.nm }}&nbsp
                                <!--<span>{{ item.item.name }}</span>-->
                            </div>
                            <span>
                                {{ item.mk ? '观众评分&nbsp' : '暂无评分' }}
                                <span class="grade">{{ item.mk ? item.mk.toFixed(1) : '  '}}</span>
                            </span>
                            <span class="text">
                                    主演：{{ item.desc}}
                            </span>
                            <span class="nation-runtime">
                                    {{ item.showInfo }}&nbsp
                                <!--|&nbsp-->
                                <!--{{ item.runtime }}分钟-->
                            </span>
                        </div>
                        <div class="btn">
                            <button>购票</button>
                        </div>
                    </div>
                </div>
                <div class="part"></div>
            </li>
        </ul>
    </div>
</div>
<script>

    //对html中数据进行过滤、加工，但Vue3不支持
    Vue.filter("imgFilter", (url) => {
        return url.replace('w.h/', '') + '@1l_1e_1c_120w_180h'
    })

    new Vue({
        el: "#box",
        data: {
            switchClass: false,
            datalist: [],
            actorsList: []
        },
        created() {
            this.handleHot()
        },
        methods: {
            handleHot() {
                axios.get("./json/maoyan.json").then(res => {
                    console.log(res.data.data.hot);
                    this.datalist = res.data.data.hot;

                    this.switchClass = false;
                })
            },
            handleComing() {
                this.switchClass = true
            }
        }
    })
</script>
</body>
</html>